﻿
var ns, toast, actionsheet;
var app = new Vue({
    el: '#app',
    data: {
        form: {
            ID: 0,
            AppointTime: '',
            CompleteArea:0,
            ReturnPassNumber:0
        },
    },
    methods: {
        do_save: function () {
            var that = this;
            var options = {};
            options.ID = that.form.ID;
            options.CompleteTime = that.form.AppointTime;
            options.CompleteArea = that.form.CompleteArea;
            options.ReturnPassNumber = that.form.ReturnPassNumber;
            options.action = "registercomplete";
            ns.post(options, function (succeed, data, err) {
                if (succeed) {
                    api.toast({
                        msg: '结算成功',
                        duration: 2000,
                        location: 'bottom'
                    });
                    
                } else {
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            })
        },
        do_select_time: function () {
            var that = this;
            api.openPicker({
                type: 'date',
                date: that.form.AppointTime,
                title: '选择日期'
            }, function (ret, err) {
                if (ret) {
                    var year = ret.year;
                    var month = (ret.month >= 10 ? ret.month : '0' + ret.month);
                    var day = (ret.day >= 10 ? ret.day : '0' + ret.day);
                    api.openPicker({
                        type: 'time',
                        title: '选择时间'
                    }, function (ret2, err2) {
                        if (ret2) {
                            var hour = (ret2.hour >= 10 ? ret2.hour : '0' + ret2.hour);
                            var minute = (ret2.minute >= 10 ? ret2.minute : '0' + ret2.minute);
                            that.form.AppointTime = year + '-' +
                                month + '-' +
                                day + ' ' + hour + ':' + minute;
                        }
                    });
                }
            });
        },
    }
});

apiready = function () {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.form.ID = api.pageParam.ID || 0;
    setTimeout(function () {
        app.form.AddCustomerName = api.getPrefs({
            sync: true,
            key: 'loginname'
        });
    }, 500)
    toast = new auiToast();
    actionsheet = new auiActionsheet();

};
